<?php

namespace App\Models\Scope;

use Illuminate\Database\Eloquent\Scope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;

class NeighborHelpCommentScope implements Scope
{
	/**
	 * 应用作用域
	 *
	 * @param  \Illuminate\Database\Eloquent\Builder  $builder
	 * @param  \Illuminate\Database\Eloquent\Model  $model
	 * @return void
	 */
	public function apply(Builder $builder, Model $model)
	{
		return $builder->select(DB::raw('neighbor_help_comment.id,parent_id,help_id,uid,comment,neighbor_help_comment.created_at,username,avatar,u.mobile'))->leftJoin('client_user as u','neighbor_help_comment.uid','=','u.id')->where('neighbor_help_comment.status', '=', 1);
	}
}